package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindBook implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书");
        System.out.println("输入要找的书名或者作者姓名");
        Scanner scanner=new Scanner(System.in);
        String Name=scanner.nextLine();
        int currentSize=bookList.getUseSize();
        for (int i = 0; i <currentSize ; i++) {
            Book book=bookList.getBook(i);
            if (book.getName().equals(Name)){
                System.out.println("找到了！！！");
                System.out.println(book);
                return;
            }
            if(book.getAuthor().equals(Name)){
                System.out.println("找到了！！！");
                System.out.println(book);
            }
        }
        System.out.println("没有该图书！！！");
    }
}
